<template>
  <div class="home-services">
    <div class="section-header">
      <h3 class="section-title">家庭服务</h3>
      <span class="all-services">全部服务</span>
    </div>
    
    <div class="services-grid">
      <div
        v-for="(service, index) in homeServiceList"
        :key="index"
        class="service-item"
        @click="handleServiceClick(service)"
      >
        <div class="service-icon">
          <img :src="service.icon" :alt="service.title" />
        </div>
        <span class="service-title">{{ service.title }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  homeServiceList: {
    type: Array,
    default: () => []
  }
})

const emit = defineEmits(['service-click'])

const handleServiceClick = (service) => {
  emit('service-click', service)
}
</script>

<style scoped>
.home-services {
  background-color: #fff;
  margin: 0 16px 20px;
  border-radius: 16px;
  padding: 20px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.all-services {
  font-size: 14px;
  color: #666;
  cursor: pointer;
}

.all-services:hover {
  color: #409eff;
  text-decoration: underline;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px 8px;
}

.service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s ease;
  padding: 8px 4px;
  border-radius: 8px;
}

.service-item:hover {
  transform: translateY(-2px);
  background-color: #f8f9fa;
}

.service-item:active {
  transform: translateY(0);
}

.service-icon {
  width: 36px;
  height: 36px;
  background-color: #f0f8ff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border: 1px solid #e1f3ff;
  transition: all 0.2s ease;
}

.service-item:hover .service-icon {
  background-color: #e1f3ff;
  border-color: #409eff;
}

.service-icon img {
  width: 20px;
  height: 20px;
  filter: brightness(0.8);
}

.service-title {
  font-size: 12px;
  color: #333;
  text-align: center;
  line-height: 1.2;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .home-services {
    margin: 0 12px 16px;
    padding: 16px 12px;
  }
  
  .section-header {
    margin-bottom: 16px;
  }
  
  .section-title {
    font-size: 16px;
  }
  
  .all-services {
    font-size: 12px;
  }
  
  .services-grid {
    gap: 12px 6px;
  }
  
  .service-item {
    padding: 6px 2px;
  }
  
  .service-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
  }
  
  .service-icon img {
    width: 18px;
    height: 18px;
  }
  
  .service-title {
    font-size: 11px;
  }
}
</style>
